/*
 * Copyright (C) 2015 yixun All Rights Reserved.
 * 
 * PremisesStatusEnum.java
 */
package com.yixun.qfbao.xf.model.enums;

import java.io.Serializable;

import org.apache.commons.lang.StringUtils;

/**
 * 	楼盘来源
 * @author zilong.liu
 * @date 2020-12-10
 *
 */
public enum PremisesOriginEnum implements Serializable{
	
		// 楼盘只能用t
		typeNotChoose("-1", "未选择", " and 0 = 1 "),
		type0("0", "全部", ""),
		type1("1", "恒信", " and t.name like '%恒信%'"),
		type2("2", "恒信合作厂商", "and t.name not like '%恒信%'"),
		;
		
		private final String no;
		private final String des;
		private final String extraSql;
		
		/**
		 * 私有构造函数
		 * @param no
		 * @param des
		 */
		PremisesOriginEnum(String no, String des, String extraSql) {
			this.no = no;
			this.des = des;
			this.extraSql = extraSql;
		}

		/**
		 * @return Returns the no.
		 */
		public String getNo() {
			return no;
		}

		/**
		 * @return Returns the des.
		 */
		public String getDes() {
			return des;
		}
		
		public String getExtraSql() {
			return extraSql;
		}

		/**
		 * 通过枚举<code>des</code>获得枚举
		 * 
		 * @param des
		 * @return
		 */
		public static PremisesOriginEnum getByDescription(String des) {
			if(StringUtils.isBlank(des)){
				return null;
			}
			for (PremisesOriginEnum menum : values()) {
				if (menum.getDes().equals(des)) {
					return menum;
				}
			}
			return null;
		}
		
		public static PremisesOriginEnum getByNo(String no) {
			if(StringUtils.isBlank(no)){
				return null;
			}
			for (PremisesOriginEnum menum : values()) {
				if (menum.getNo().equals(no)) {
					return menum;
				}
			}
			return null;
		}
}
